﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Homework01
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txt_zsxm.Text) || string.IsNullOrWhiteSpace(this.txt_nl.Text) || string.IsNullOrWhiteSpace(this.txt_xx.Text))
            {
                MessageBox.Show("不能为空");
                return;
            }
            int age = Convert.ToInt32(this.txt_nl.Text);
            if (rbto_nan.Checked)
            {
                MessageBox.Show($"我的姓名为:{this.txt_zsxm}, 性别为:{this.rbto_nan.Text}, 年龄为:{this.txt_nl.Text}, 血型为:{this.txt_xx.Text}");
            }
            else
            {
                MessageBox.Show($"我的姓名为:{this.txt_zsxm.Text}, 性别为:{this.rbto_nan.Text}, 年龄为:{age}, 血型为:{this.txt_xx.Text}");
            }

        }

        private void txt_nl_KeyPress(object sender, KeyPressEventArgs e)
        {

            if (e.KeyChar != '\b' && !Char.IsDigit(e.KeyChar))
            {
                //限制输入
                e.Handled = true;
            }
        }
    }
}
